﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestClientMode.aspx.cs" Inherits="TestCase_TestClientMode" %>

<%@ Register src="../dotNetFlexGrid/dotNetFlexGrid.ascx" tagname="dotNetFlexGrid" tagprefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<script language="javascript" type="text/javascript">
    function ShowCurrentRows() {
        var rows = dotNetFlexGrid1.getSelectedRowsIds();
        for (var i = 0; i < rows.length; i++) {
            alert(rows[i]);
        }
    }
    function InsertNewRows() {
        dotNetFlexGrid1.insertNewRow({
            id: 'newid' + Math.round(Math.random() * 10000), //行的ID，后台绑定的是主键
            cell: [
                    "new_guid",
                    "f1",
                    "f2",
                    "f3",
                    "f4",
                    'f5',
                    'f6',
                    'f7'
            ]
        });
    }
    function reflashData() {
        dotNetFlexGrid1.reflashData();
    }
    function RemoveRows() {
        dotNetFlexGrid1.deleteRows(dotNetFlexGrid1.getSelectedRowsIds());
    }
    function getCellData() {
        var id = dotNetFlexGrid1.getSelectedRowsIds()[0];
        if (id) {
            var array = dotNetFlexGrid1.getCellDatas(id);
            if (array) {
                for (var i = 0; i < array.length; i++) {
                    alert(array[i]);
                }
            }
        }
    }
    function EditRows() {
         var id = dotNetFlexGrid1.getSelectedRowsIds()[0];
         if (id) {
             dotNetFlexGrid1.updateRowData({
                 id: id,
                 cell: [
                    "edt_guid" + Math.round(Math.random() * 10000), 
                    "e_f1",
                    "e_f2",
                    "e_f3",
                    "e_f4",
                    'e_f5',
                    'e_f6',
                    'e_f7'
                    ]
             });
         }
    }
    
</script>
<body>
    <form id="form1" runat="server">
    <div>
    <a href="javascript:ShowCurrentRows();">显示当前选择的Rows</a>
    <a href="javascript:InsertNewRows();">新增一行</a>
    <a href="javascript:EditRows();">修改当前行</a>
    <a href="javascript:RemoveRows();">删除当前选择的行</a>
    <a href="javascript:reflashData();">直接刷新Grid</a>
    <a href="javascript:getCellData();">获取一行数据</a>
    <br />
    </div>
    <uc1:dotNetFlexGrid ID="dotNetFlexGrid1" runat="server" />
    </form>
</body>
</html>
